package se19team1e.gui.awt;

import java.util.Vector;

import javax.swing.table.AbstractTableModel;

/**
 * Generic Table model extends from Abstract Table Model to display the search
 * items in a presentable form
 * 
 * @author arun
 * 
 */
public class GenericJTableModel extends AbstractTableModel {

	Vector<String> header = null;
	Vector<Vector> data = null;

	/**
	 * Constructor class using null values as default
	 * 
	 * @param header
	 *            vector of type string is required
	 * @param data
	 *            vector of type vectors is required
	 */
	public GenericJTableModel(Vector<String> header, Vector<Vector> data) {
		this.header = header;
		this.data = data;
	}

	/**
	 * Getter to get the number of row
	 * 
	 * @return size of data given by number of row used
	 */
	@Override
	public int getRowCount() {
		return data.size();
	}

	/**
	 * Getter to get the count of header fields
	 * 
	 * @return the count of column
	 */
	@Override
	public int getColumnCount() {
		return header.size();
	}

	/**
	 * To obtain the value at a particular row and column
	 * 
	 * @param rowIndex
	 *            The integer value for row
	 * @param columnIndex
	 *            The integer value for column
	 * @return object that is in the given table
	 */
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return data.get(rowIndex).get(columnIndex);
	}

	/**
	 * Getter to het the column name (also known as the header fields)
	 * 
	 * @param integer
	 *            that represents the column specified
	 * @return Cast the column value into a String
	 */
	@Override
	public String getColumnName(int column) {
		return (String) header.get(column);
	}

	/**
	 * Check if the cell can be edited
	 * 
	 * @return false always as all items in table are non-changeable
	 */
	@Override
	public boolean isCellEditable(int row, int col) {
		return false;
	}

}
